/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class SOPRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long sopId;
    
    private int month;
    private int year;
    private int productionPlanFigure;
    private int inventoryFigure;
    private int workingDays;
    private int capacity;
    private double utilization;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private SalesForecastRecord sfr;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private ProdRecordSOP prsop;
    
    
    public void create(int mth, int yr, int pFig, int iFig, int wDays, int cap, double util,SystemUser user)
    {
        this.setMonth(mth);
        this.setYear(yr);
        this.setProductionPlanFigure(pFig);
        this.setInventoryFigure(iFig);
        this.setWorkingDays(wDays);
        this.setCapacity(cap);
        this.setUtilization(util);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }
    
    public int getCapacity() {
        return capacity;
    }

    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public int getInventoryFigure() {
        return inventoryFigure;
    }

    public void setInventoryFigure(int inventoryFigure) {
        this.inventoryFigure = inventoryFigure;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public ProdRecordSOP getPrsop() {
        return prsop;
    }

    public void setPrsop(ProdRecordSOP prsop) {
        this.prsop = prsop;
    }

    public SalesForecastRecord getSfr() {
        return sfr;
    }

    public void setSfr(SalesForecastRecord sfr) {
        this.sfr = sfr;
    }

    public int getProductionPlanFigure() {
        return productionPlanFigure;
    }

    public void setProductionPlanFigure(int ppFigure) {
        this.productionPlanFigure = ppFigure;
    }

    public Long getSopId() {
        return sopId;
    }

    public void setSopId(Long sopId) {
        this.sopId = sopId;
    }

    public double getUtilization() {
        return utilization;
    }

    public void setUtilization(double utilization) {
        this.utilization = utilization;
    }

    public int getWorkingDays() {
        return workingDays;
    }

    public void setWorkingDays(int workingDays) {
        this.workingDays = workingDays;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }
    
    
    public Long getSOPId() {
        return sopId;
    }

    public void setSOPId(Long id) {
        this.sopId = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sopId != null ? sopId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SOPRecord)) {
            return false;
        }
        SOPRecord other = (SOPRecord) object;
        if ((this.sopId == null && other.sopId != null) || (this.sopId != null && !this.sopId.equals(other.sopId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.SOPRecord[ id=" + sopId + " ]";
    }
    
}
